﻿@model InvoiceModel
@using Telerik.Web.Mvc.UI;
@using Nop.Core.Domain.Tax;
@using Nop.Core.Domain.Catalog;
@{
    var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSize;
    
    //var PaymentInfoActionName=
    //var PaymentInfoControllerName=
    //    var PaymentInfoRouteValues=
}

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.OrderIds)

@Html.HiddenFor(model => model.StartDate)
@Html.HiddenFor(model => model.EndDate)
@Html.HiddenFor(model => model.InvoiceStatusId)
@Html.HiddenFor(model => model.OrderKindId)

<table class="adminContent">
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.CustomerId):
        </td>
        <td class="adminData">
            @Html.DropDownList("CustomerId", Model.AvailableCustomers)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Name):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Name)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.DueDate):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.DueDate)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.TimeZoneId):
        </td>
        <td class="adminData">
            @Html.DropDownListFor(model => model.TimeZoneId, Model.AvailableTimeZones)
        </td>
    </tr>
    @if (Model.OrderKindId == (int)Nop.Core.Domain.Orders.OrderKind.Commerce)
    {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.MonthlyCharge):
            </td>
            <td class="adminData">
                @Html.DisplayFor(model => model.MonthlyCharge)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.StorageCharge):
            </td>
            <td class="adminData">
                @Html.DisplayFor(model => model.StorageCharge)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.ServiceCharge):
            </td>
            <td class="adminData">
                @Html.DisplayFor(model => model.ServiceCharge)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.TransactionProcessingCharge):
            </td>
            <td class="adminData">
                @Html.DisplayFor(model => model.TransactionProcessingCharge)
            </td>
        </tr>
    }
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.SubTotal):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.SubTotal)
        </td>
    </tr>
    @if (Model.FuelSurcharge.HasValue)
    {
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.FuelSurcharge):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.FuelSurcharge)
            </td>
        </tr>
    }
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Tax):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Tax)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Total):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Total)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Discount):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.Discount)
        </td>
    </tr>
    @*<tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Payment):
        </td>
        <td class="adminData">
            @Html.Action(Model.PaymentActionName, Model.PaymentControllerName, Model.PaymentRoute)
        </td>
    </tr>*@
</table>
<p></p>
<table class="adminContent">
    <tr>
        <td>
            @* Hiding grid table's refresh button *@
            @Html.Telerik().ScriptRegistrar().OnDocumentReady("$('#orders-grid .t-status').hide();")

            @(Html.Telerik().Grid(Model.Orders)
                    .Name("orders-grid")
                    .Columns(columns =>
                    {
                        columns.Bound(x => x.Id)
                            .Template(x => String.Format("<input type='checkbox' name='checkedRecords' value='{0}' class='checkboxGroups'/>", x.Id))
                            .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= Id #>' class='checkboxGroups'/>")
                            .Title("<input id='mastercheckbox' type='checkbox'/>")
                            .Width(50)
                            .HtmlAttributes(new { style = "text-align:center" })
                            .HeaderHtmlAttributes(new { style = "text-align:center" });

                        columns.Bound(x => x.Id);
                        columns.Bound(x => x.OrderStatus);
                        columns.Bound(x => x.PaymentStatus);
                        columns.Bound(x => x.ShippingStatus);
                        columns.Bound(x => x.CustomerEmail);
                        columns.Bound(x => x.CreatedOn).ClientTemplate("<#= CreatedOnStr #>");
                        columns.Bound(x => x.OrderTotal)
                                .FooterTemplate(
                                string.Format("<div><strong>{0}:</strong></div>" +
                            //"<div>{1}: <span id=\"aggregator-profit-block\">{4}</span></div>" +
                                "<div>{1}: <span id=\"aggregator-subtotal-block\">{5}</span></div>" +
                                "<div>{2}: <span id=\"aggregator-fuelsurcharge-block\">{6}</span></div>" +
                                "<div>{3}: <span id=\"aggregator-tax-block\">{7}</span></div>" +
                                "<div>{4}: <span id=\"aggregator-total-block\">{8}</span></div>",
                                @T("Admin.Orders.Report.Summary").Text,
                                @T("Admin.Orders.Report.SubtotalExclTax").Text,
                                @T("Admin.Orders.Report.FuelSurcharge").Text,
                            //@T("Admin.Orders.Report.Profit").Text,
                                @T("Admin.Orders.Report.Tax").Text,
                                @T("Admin.Orders.Report.Total").Text,
                            //@Model.AggregatorProfit,
                                @Model.AggregatorSubtotalExcltax,
                                @Model.AggregatorFuelSurcharge,
                                @Model.AggregatorTax,
                                @Model.AggregatorTotal));
                    })
                    .Pageable(settings => settings.PageSize(gridPageSize).Position(GridPagerPosition.Both)))
        </td>
    </tr>
</table>